<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //symbol可用于给对象添加属性和方法，并且不影响原有和属性方法
        let game = {
            name: 'wz',
            up: function() {
                console.log("up up")
            },
            down: function() {
                console.log("down down")
            }
        }
        game.up()
        //扩展一个新的up方法会覆盖原有方法
        // game.up = function() {
        //     console.log("new up up")
        // }
        // game.up()

        //声明一个对象，使用symbol扩展方法
        let methods = {
            up: Symbol(),
            down: Symbol()
        }
        game[methods.up] = function() {
            console.log("new new up up")
        }
        game.up()
        game[methods.up]()
        console.log(game)

        //扩展方法的另一种方式
        let youxi = {
            name: '狼人杀',
            [Symbol('say')] : function(){ //Symbol作为key需要加[]
                console.log('发言')    
            }
        }
        console.log(youxi)

    </script>
</body>
</html>